package cn.arikeky.basic.config;

import cn.arikeky.interceptors.UserInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration// 定义此类为配置类
public class InterceptorConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // addPathPatterns拦截路径
        String[] addPathPatterns = {
//                "/**"
        };

        // excludePathPatterns排除的路径
        String[] excludePathPatterns = {
//                "/login",                    //登录路径
//                "/**/*.html",                //html静态资源
//                "/**/*.js",                  //js静态资源
//                "/**/*.css"                  //css静态资源
        };

        // 创建用户拦截器对象兵指定其拦截路径和排除拦截的路径
        registry.addInterceptor(new UserInterceptor())
                .addPathPatterns(addPathPatterns)
                        .excludePathPatterns(excludePathPatterns);
    }
}
